package com.ruoyi.web.controller.pollutant;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.pollutant.domain.OutletWater;
import com.ruoyi.pollutant.service.IOutletWaterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 废水排放口Controller
 * 
 * @author yxf
 * @date 2021-08-25
 */
@RestController
@RequestMapping("/pollutant/water")
public class OutletWaterController extends BaseController
{
    @Autowired
    private IOutletWaterService outletWaterService;

    /**
     * 查询废水排放口列表
     */
    @GetMapping("/list")
    public TableDataInfo list(OutletWater outletWater)
    {
        startPage();
        List<OutletWater> list = outletWaterService.selectOutletWaterList(outletWater);
        return getDataTable(list);
    }

    /**
     * 导出废水排放口列表
     */
    @PreAuthorize("@ss.hasPermi('pollutant:water:export')")
    @Log(title = "废水排放口", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OutletWater outletWater)
    {
        List<OutletWater> list = outletWaterService.selectOutletWaterList(outletWater);
        ExcelUtil<OutletWater> util = new ExcelUtil<OutletWater>(OutletWater.class);
        return util.exportExcel(list, "废水排放口数据");
    }

    /**
     * 获取废水排放口详细信息
     */
    @PreAuthorize("@ss.hasPermi('pollutant:water:query')")
    @GetMapping(value = "/{wwoId}")
    public AjaxResult getInfo(@PathVariable("wwoId") Long wwoId)
    {
        return AjaxResult.success(outletWaterService.selectOutletWaterById(wwoId));
    }

    /**
     * 新增废水排放口
     */
    @PreAuthorize("@ss.hasPermi('pollutant:water:add')")
    @Log(title = "废水排放口", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OutletWater outletWater)
    {
        return toAjax(outletWaterService.insertOutletWater(outletWater));
    }

    /**
     * 修改废水排放口
     */
    @PreAuthorize("@ss.hasPermi('pollutant:water:edit')")
    @Log(title = "废水排放口", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OutletWater outletWater)
    {
        return toAjax(outletWaterService.updateOutletWater(outletWater));
    }

    /**
     * 删除废水排放口
     */
    @PreAuthorize("@ss.hasPermi('pollutant:water:remove')")
    @Log(title = "废水排放口", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wwoIds}")
    public AjaxResult remove(@PathVariable Long[] wwoIds)
    {
        return toAjax(outletWaterService.deleteOutletWaterByIds(wwoIds));
    }
}
